﻿using System;
using System.Linq.Expressions;

namespace ABC.Core.Utilities
{
    public static class Lambda
    {
        public static string Property<T>(Expression<Func<T, object>> property)
        {
            var unaryExpression = property.Body as UnaryExpression;
            var memberExpression = (MemberExpression)(unaryExpression != null ? unaryExpression.Operand : property.Body);
            return memberExpression.Member.Name;
        }
    }
}